// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import App from './App'
import router from './router'
import store from './store/store.js'
import fastclick from 'fastclick'
import '@/assets/style/border.css'
import '@/assets/style/reset.css'
import '@/assets/style/iconfont.css'
import 'swiper/dist/css/swiper.css'
import 'mint-ui/lib/style.css'
import LyTab from 'ly-tab'


Vue.use(LyTab)
Vue.config.productionTip = false
//定义fastclick作用范围
fastclick.attach(document.body)
Vue.use(VueAwesomeSwiper)
/* eslint-disable no-new */

// Vue.use(router)
router.beforeEach((to, from, next) => {
  // to and from are both route objects. must call `next`.
     let islogin=JSON.parse(localStorage.islogin) 
  // let islogin = store.state.islogin
  if(to.path=="/xiaox" && !islogin){
    next("/login")
  }else{
    next() 
  }
  if(to.path=="/wode"&& !islogin){
    next("/login")
  }else{
    next()
  }
  // if(to.path =="/login"){
  //   if(!islogin){
  //     next();
  //   }else{
  //     router.replace("/");
  //   }
  // }else{
  //   if(!islogin){
  //     router.replace({path:"/login",query:{redirect:to.name}});
  //   }else{
  //     next();
  //   }
  // }
})

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>',
  mounted(){
      // 新建地图实例作用加载到在allmap中
      let map=new BMap.Map('allmap')
      // 获取城市  
      let myCity = new BMap.LocalCity()
      myCity.get((result)=>{
          // 判断有没有result
          if(result){
              // 有就把城市名字存放在我的本地city中
              this.$store.state.city=result.name
          }else{
            this.$store.state.city='北京'
          }
      })
  }
})




